//package cn.com.headfree.base.config;
//
//import cn.com.headfree.base.service.SysDictionaryInfoService;
//import cn.com.headfree.util.RedisClusterUtil;
//import cn.com.headfree.vo.SysDictionaryInfoVo;
//import com.alibaba.fastjson.JSONObject;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.stereotype.Component;
//
//import javax.annotation.PostConstruct;
//import javax.annotation.PreDestroy;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//
//@Component
//public class CodeCache {
//    public  Map<String, List<SysDictionaryInfoVo>> codeMap = new HashMap<String, List<SysDictionaryInfoVo>>();
//    private static int dictionaryTime;
//    @Value("${redis.dictionary.timelong}")
//    public void setDictionaryTime(int dictionaryTime) {
//        this.dictionaryTime = dictionaryTime;
//    }
//
//    @Autowired
//    SysDictionaryInfoService sysDictionaryInfoService;
//
//    @PostConstruct
//    public void init(){
//        System.out.println("系统启动中。。。加载codeMap");
//        String pId = "6d81ed6c864046ffb564e78912ab2c10";
//        List<SysDictionaryInfoVo>  list = sysDictionaryInfoService.getSysDictionaryInfo(pId);
//        for (SysDictionaryInfoVo code : list) {
//            List<SysDictionaryInfoVo> entityList = sysDictionaryInfoService.getSysDictionaryInfo(code.getId());
//            codeMap.put(code.getValue(),entityList);
//        }
//        if (codeMap != null) {
//            RedisClusterUtil.getInstance().setString("sysdictionary-info-", JSONObject.toJSONString(codeMap), dictionaryTime);
//        }
//    }
//
//    @PreDestroy
//    public void destroy(){
//        System.out.println("系统运行结束");
//    }
//}
